<template>
  <view class="query-box">
    <tm-sheet style="border-radius: 2px">
      <tm-text :font-size="24" _class="text-weight-b" label="输入金额"></tm-text>
      <tm-divider></tm-divider>
      <tm-input prefix="tmicon-ios-man" placeholder="金额" v-model="number" suffixLabel=""/>
      <view class="flex flex-row flex-row-center flex-col-center-center flex-1" style="margin-top: 5px">
        <tm-button :round="2" label="计算" :font-size="24" :width="1600" :height="60" @click="search"></tm-button>
      </view>
    </tm-sheet>
  </view>
  <view>

  </view>
</template>

<script>
import properties from "@/common/properties";

export default {
  data() {
    return {
      number: null,
      audioSrc: ''
    }
  },
  methods: {
    search(e) {
      var innerAudioContext = uni.createInnerAudioContext();
      innerAudioContext.autoplay = true;
      innerAudioContext.src = properties.baseURL + "/test/amount-pinyin?number=" + this.number + "&token=" + uni.getStorageSync(properties.token_name);
      innerAudioContext.onPlay(() => {
        console.log('开始播放');
      });
      // amountPinyin({number: this.number}).then(res => {
      //   console.log('res',res)
      //
      //   // 将响应体blob转换为URL.createObjectURL形式
      //   this.audioSrc = URL.createObjectURL(new Blob([res], {type: 'audio/mp3'}));
      //
      //   var innerAudioContext = uni.createInnerAudioContext();
      //   innerAudioContext.autoplay = true;
      //   console.log('src',this.audioSrc)
      //   innerAudioContext.src = this.audioSrc;
      //   innerAudioContext.onPlay(() => {
      //     console.log('开始播放');
      //   });
      // })
    }
  }
}
</script>

<style scoped>

</style>
<style lang="scss">
page {
  background-color: #F7F7F7 !important;
}
</style>
